using System;
using System.Drawing;

namespace CCAI.Office.PowerPoint.TimedText.Captions
{
    /// <summary>
    /// Represents styling settings for a CaptionMediaMarker object.
    /// </summary>
    /// <remarks>
    /// <para>
    /// This class is used to apply text styling settings defined in the W3C Timed Text Markup Language to a CaptionMediaMarker object.
    /// For more detailed information, see http://www.w3.org/TR/ttaf1-dfxp/#styling
    /// </para>
    /// <para>
    /// Note that members have a <c>[ScriptableMember]</c> attribute allowing them to be accessed from your JavaScript code.
    /// </para>
    /// </remarks>
    public class TimedTextStyle// : DependencyObject
    {
        private const string DefaultFontFamilyName = "Calibri";
        private const DisplayAlign DefaultDisplayAlign = DisplayAlign.Before;
        private const double DefaultOpacity = 1;
        private const Overflow DefaultOverflow = Overflow.Hidden;
        private const ShowBackground DefaultShowBackground = ShowBackground.Always;
    //    private const TextAlignment DefaultTextAlignment = TextAlignment.Center;
  //      private const Visibility DefaultVisibility = Visibility.Visible;
   //     private const TextWrapping DefaultWrapOption = TextWrapping.Wrap;
        private static readonly Color DefaultColor = Color.White;//new SolidColorBrush(Colors.White);
        private static readonly Color DefaultBackgroundColor = System.Drawing.Color.Black;
        private static readonly Extent DefaultExtent = Extent.Auto;
        private static readonly FontFamily DefaultFontFamily = new FontFamily(DefaultFontFamilyName);
        private static readonly FontStyle DefaultFontStyle = System.Drawing.FontStyle.Regular;
        private static readonly FontStyle DefaultFontWeight = System.Drawing.FontStyle.Regular;
        private static readonly Origin DefaultOrigin = Origin.Empty;
        private static readonly Padding DefaultPadding = Padding.Empty;

        public TimedTextStyle()
        {
            BackgroundColor = DefaultBackgroundColor;
            Color = DefaultColor;
            DisplayAlign = DefaultDisplayAlign;
            Extent = DefaultExtent;
            FontFamily = DefaultFontFamily;
            FontSize = new Length
            {
                Unit = LengthUnit.Pixel,
                Value = 12
            };
            FontStyle = DefaultFontStyle;
            FontWeight = DefaultFontWeight;
            Id = Guid.NewGuid().ToString();
            LineHeight = null;
            Opacity = DefaultOpacity;
            Origin = DefaultOrigin;
            Overflow = DefaultOverflow;
            Padding = DefaultPadding;
            ShowBackground = DefaultShowBackground;
            //TextAlign = DefaultTextAlignment;
            //Visibility = DefaultVisibility;
            //WrapOption = DefaultWrapOption;
        }

        /// <summary>
        /// Gets or sets an identifier.
        /// </summary>
        /// <remarks>
        /// The Id is used when polling occurs to determine which of the caption markers are new.
        /// </remarks>
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets the background color for the caption.
        /// </summary>
        public Color BackgroundColor { get; set; }

        /// <summary>
        /// Gets or sets the foreground text color for the caption.
        /// </summary>
        public Color Color { get; set; }

        /// <summary>
        /// Gets or sets the font family for the caption.
        /// </summary>
        public FontFamily FontFamily { get; set; }

        /// <summary>
        /// Text representation of FontFamily.  Really only here to support XML serialization.
        /// </summary>
        public string FontFamilyText
        {
            get
            {
                return FontFamily != null
                           ? FontFamily.Name
                           : string.Empty;
            }

            set
            {
                FontFamily = !string.IsNullOrEmpty(value)
                                 ? new FontFamily(value)
                                 : null;
            }
        }

        /// <summary>
        /// Gets or sets the text size for the caption.
        /// </summary>
        /// <remarks>
        /// The only unit of measurement supported is pixels (px).
        /// </remarks>
    //    [ScriptableMember]
        public Length FontSize { get; set; }

        /// <summary>
        /// Gets or sets the text style for the caption.
        /// </summary>
        /// <remarks>
        /// Only Normal and Italic styles are supported.
        /// </remarks>
   //     [ScriptableMember]
        public FontStyle FontStyle { get; set; }

        /// <summary>
        /// Gets or sets the font weight for the caption.
        /// </summary>
 //       [ScriptableMember]
        public FontStyle FontWeight { get; set; }

        /// <summary>
        /// Gets or sets the line height for the caption.
        /// </summary>
        /// <remarks>
        /// The only unit of measurement supported is pixels (px).
        /// </remarks>
    //    [ScriptableMember]
        public Length LineHeight { get; set; }

        /// <summary>
        /// Gets or sets the percent that the caption is transparent (as a value between 0 and 1.0).
        /// </summary>
  //      [ScriptableMember]
        public double Opacity { get; set; }

        /// <summary>
        /// Gets or sets the margin for the caption.
        /// </summary>
 //       [ScriptableMember]
        public Origin Origin { get; set; }

        /// <summary>
        /// Gets or sets the amount of padding used for the caption.
        /// </summary>
  //      [ScriptableMember]
        public Padding Padding { get; set; }

        /// <summary>
        /// Gets or sets the text alignment setting for the caption.
        /// </summary>
        /// <remarks>
        /// The only horizontal text alignments supported are left, center, and right.
        /// </remarks>
 //       [ScriptableMember]
     //   public TextAlignment TextAlign { get; set; }

        /// <summary>
        /// Gets or sets the visibility of the caption.
        /// </summary>
 //       [ScriptableMember]
    //    public Visibility Visibility { get; set; }

        /// <summary>
        /// Gets or sets the display of the caption, this differs from visibility because visibility still takes space.
        /// </summary>
  //      [ScriptableMember]
   //     public Visibility Display { get; set; }

        /// <summary>
        /// Gets or sets the text wrapping setting for the caption.
        /// </summary>
  //      [ScriptableMember]
    //    public TextWrapping WrapOption { get; set; }

        /// <summary>
        /// Gets or sets the display alignment for the caption.
        /// </summary>
  //      [ScriptableMember]
        public DisplayAlign DisplayAlign { get; set; }

        /// <summary>
        /// Gets or sets when the background should be displayed for the caption.
        /// </summary>
  //      [ScriptableMember]
        public ShowBackground ShowBackground { get; set; }

        /// <summary>
        /// Gets or sets the overflow for the caption.
        /// </summary>
//        [ScriptableMember]
        public Overflow Overflow { get; set; }

        /// <summary>
        /// Gets or sets the extent for the caption.
        /// </summary>
   //     [ScriptableMember]
        public Extent Extent { get; set; }

        /// <summary>
        /// Gets or sets the zindex for the caption.
        /// </summary>
        public int ZIndex { get; set; }

        /// <summary>
        /// Creates a memberwise close of this style.
        /// </summary>
        /// <returns></returns>
        public TimedTextStyle Clone()
        {
            return MemberwiseClone() as TimedTextStyle;
        }
    }
}